﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace wd_5_file_helper
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            deletefile.Text = "D:\\8-big\\1-wav\\speech\\1-ninbo.wav";
            deletedir.Text = "D:\\8-big\\1-wav\\speech";
        }

        private void Button_Click_Delete(object sender, RoutedEventArgs e)
        {

            string str1 = this.deletefile.Text;
            if (File.Exists(str1))
            {
                //https://blog.csdn.net/cillent_boy/article/details/103362123
                //Directory.Delete()
                File.Delete(str1);
            } 
            else
            {
                MessageBox.Show("no file");
            }
        }

        private void Button_Click_Copy(object sender, RoutedEventArgs e)
        {
            copyfile.Text = "D:\\xinan-git\\6-audio-recognition\\1-master\\4-paddlespeech-run\\1-ninbo.wav";
            string str1 = copyfile.Text;
            string str2 = deletefile.Text;
            if (File.Exists(str1))
            {
                System.IO.File.Copy(str1, str2, true);
            } 
            else
            {
                MessageBox.Show("no file");
            }
        }

        private void Button_Click_Clear(object sender, RoutedEventArgs e)
        {
            string str1 = deletedir.Text;

            if(File.Exists(str1))
            {
                DirectoryInfo di = new DirectoryInfo(str1);
                di.Delete(true);  //删除目录
            }
            else
            {

            }
        }
    }
}
